﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Windows;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Database;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SummaryForm.xaml
    /// </summary>
    public partial class VK02AV95 : DocumentBase
    {
        #region-------------Properties-----------------------
        public OracleConnection OracleDB;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicParamater;
        public INTEXDataSet setUI
        {
            get
            {
                return (INTEXDataSet)TryFindResource("iNTEXDataSet");
            }
        }
        VK02AV95Data m_Data, m_DataX;
        public DataSet setResult;
        
        private DataRow dwVKPOS;
        
        int finishedcount = 0;
        int totalrecord = 0;
        #endregion
        public VK02AV95()
        {
            InitializeComponent();
            this.Name = "销售单一览表";
        }
        public override void SetUp(Dictionary<string, object> dicParamater)
        {
            base.SetUp(dicParamater);
            InitializeComponent();
           

            this.dicParamater = dicParamater;
            OracleDB = (OracleConnection)dicParamater["OracleDB"];
            proxy = (IntexReptServBLClient)dicParamater["proxy"];
            orlReadCommand = OracleDB.CreateCommand();
            orlReadCommand.Parameters.Add("OrdNum", OracleType.NVarChar).Value = "";
            
            m_Data = new VK02AV95Data();
            m_Data.OracleDB = this.OracleDB;
            m_Data.proxy = this.proxy;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
             
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }
        private void btnQuery_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                finishedcount = 0;
                setUI.Clear(); 
               
                foreach (DataRow dwNABPOS in setUI.ABPOS)
                {
                    m_Data = new VK02AV95Data ();
                    m_Data.OracleDB = this.OracleDB;
                    m_Data.proxy = this.proxy;
                    EventDispatcher.Instance.RaiseUIMessage(m_Data, dwNABPOS);
                }
                tbStatus.Text = "查询进展中";
            }
            catch (Exception ex)
            {

                Tracer.Error(ex.StackTrace, ex);

            }
        } 
        private void btnReport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AB55AV95Report m_rpt = new AB55AV95Report(dicParamater);
                m_rpt.dsSource = setUI;
                m_rpt.exAgent = m_Data.exAgent;
                m_rpt.WriteExcelReport("EXCEL");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

    }
}
